package com.kasax.skin2.fragment;

import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.RecyclerView;

import com.kasax.skin2.R;
import com.kasax.skin2.adapter.MyRecyclerViewAdapter;

import java.util.Arrays;

public class MusicFragment extends Fragment {

    private View rootView;
    private RecyclerView recyclerView;
    private Context mCtx;

    @Override
    public void onAttach(@NonNull Context context) {
        super.onAttach(context);
        this.mCtx = context;
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        rootView = inflater.inflate(R.layout.layout_music, container, false);
        return rootView;
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);

        recyclerView = rootView.findViewById(R.id.recyclerview);
        recyclerView.setAdapter(new MyRecyclerViewAdapter(mCtx, Arrays.asList(view.getContext().getResources().getStringArray(R.array.music_list))));
    }
}
